package cn.edu.fudan.autoparser;
import java.io.IOException;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class QQAutoHTMLParser extends AutoHTMLParser {

	public QQAutoHTMLParser(String basicURL, String subURL) {
		super(basicURL, subURL);
	}

	@Override
	public void getHTML() throws IOException {
		Document doc = null;
		doc=Jsoup.connect(basicURl+subURL).get();
		Elements elements=doc.getElementsByAttributeValue("bosszone", "showAll");
		if(elements.size()>0){
			Elements links=elements.get(0).getElementsByTag("a");
			if(links.size()>0){
				String newURL=basicURl+links.get(0).attr("href");
				doc=Jsoup.connect(newURL).get();
			}
		}
		HTML=doc;
	}

	@Override
	public void parseHTML() {
		Elements title=HTML.getElementsByTag("h1");
		Element content = HTML.getElementById("Cnt-Main-Article-QQ");
		this.tiltle=title.get(0).text();
		this.content=content.text();
	}

}
